<template>
	<view class="container" v-if="!isLoading">
		<view class="box">
			<view class="item">
				<view class="title">词汇本</view>
			</view>
			<view class="item-content">

				<view class="shuru">
					<text>{{detail.book_name}}</text>
				</view>
				<view style="padding-top: 10rpx;font-size: 28rpx;">
					<text>词汇量：{{detail.book.total_num}}个</text>
				</view>

			</view>

			<view class="two-box">
				<view style="width: 65%;">
					<view class="item">
						<view class="title">词汇范围</view>
					</view>
					<view style="display: flex;padding: 30rpx 20rpx;">
						<view class="shuru" style="width: 140rpx;text-align: center;padding-left: 0rpx;">
							<text>{{detail.start_num}}</text>
						</view>
						<view style="display: flex;justify-content: center;align-items: center;padding: 0 30rpx;">
							<view style="width: 24rpx;border-bottom: solid 4rpx #BBBBBB;"></view>
						</view>
						<view class="shuru" style="width: 140rpx;text-align: center;padding-left: 0rpx;">
							<text>{{detail.end_num}}</text>
						</view>
					</view>

				</view>

				<view style="width: 30%;">
					<view class="item">
						<view class="title">抽查个数</view>
					</view>
					<view style="display: flex;padding: 30rpx 20rpx;">
						<view class="shuru" style="width: 140rpx;text-align: center;padding-left: 0rpx;">
							<text>{{detail.choose_num}}</text>
						</view>

					</view>
				</view>


			</view>


			<view class="item">
				<view class="title">抽查形式</view>
			</view>
			<view class="item-content">

				<view class="type">
					<text>{{detail.type_text}}</text>
				</view>


			</view>
			<view class="item">
				<view class="title">单个单词填写时长（S）</view>
			</view>
			<view class="item-content">

				<view class="shuru" style="width: 140rpx;padding-left: 0;text-align: center;">
					<text>{{detail.time}}</text>
				</view>


			</view>
			<view class="item">
				<view class="title">通过率（%）</view>
			</view>
			<view class="item-content">

				<view class="shuru" style="width: 140rpx;padding-left: 0;text-align: center;">
					<text>{{detail.suc}}</text>
				</view>


			</view>

			<view class="item">
				<view class="title">学生姓名</view>
			</view>
			<view class="item-content">

				<view class="shuru">
					<text>{{detail.name}}</text>
				</view>


			</view>
		</view>

		<view class="foot">

			<view class="btn" @click="toExam">
				开始考试
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getSceneData
	} from '@/core/app'
	import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
	import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
	import * as PaperApi from '@/api/ant/paper'
	import {
		getEmptyPaginateObj,
		getMoreListData
	} from '@/core/app'

	const pageSize = 15


	export default {
		components: {
			MescrollBody
		},
		mixins: [MescrollMixin],
		data() {
			return {
				isLoading: true,
				paperId: 0,
				detail: {}
			}
		},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {



			// 记录query参数
			this.onRecordQuery(options)
			this.getPaperDetail()
		},

		methods: {




			// 记录query参数
			onRecordQuery(query) {
				const scene = getSceneData(query)
				this.paperId = query.paperId ? parseInt(query.paperId) : parseInt(scene.oid)
			},
			getPaperDetail() {
				const app = this
				app.isLoading = true
				//app.paperId = 24
				PaperApi.detail(app.paperId)
					.then(result => {
						app.detail = result.data.detail

					})
					.finally(() => app.isLoading = false)
			},

			toExam() {
				uni.navigateTo({
					url: '/pages/ant/exam/detail?paperId=' + this.paperId
				})
			},

			/**
			 * 上拉加载的回调 (页面初始化时也会执行一次)
			 * 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
			 * @param {Object} page
			 */
			upCallback(page) {
				const app = this
				// 设置列表数据
				app.getHelpList(page.num)
					.then(list => {
						const curPageLen = list.data.length
						const totalSize = list.data.total
						app.mescroll.endBySize(curPageLen, totalSize)
					})
					.catch(() => app.mescroll.endErr())
			},

			// 获取帮助列表
			getHelpList(pageNo = 1) {
				const app = this
				return new Promise((resolve, reject) => {
					HelpApi.list({
							page: pageNo
						})
						.then(result => {
							// 合并新数据
							const newList = result.data.list
							app.list.data = getMoreListData(newList, app.list, pageNo)
							resolve(newList)
						})
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 20rpx 60rpx;
	}

	.foot {
		position: fixed;
		bottom: 0;
		width: 100%;
	}

	.btn {
		width: 100%;
		height: 100rpx;
		border-radius: 60rpx;
		background: linear-gradient(180deg, rgba(22, 132, 252, 1) 0%, rgba(100, 174, 255, 1) 100%);
		color: rgba(255, 255, 255, 1);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.two-box {
		display: flex;
		justify-content: space-between;

	}

	.title {
		height: 32rpx;
		border-left: solid 6rpx #64AEFF;
		font-size: 28rpx;
		color: rgba(16, 16, 16, 1);
		font-weight: bold;
		padding-left: 10rpx;
	}

	.item-content {
		padding: 30rpx 20rpx;


	}

	.shuru {

		width: 100%;
		background-color: #F1F7F7;
		height: 80rpx;
		border-radius: 8rpx;
		color: #1684FC;
		line-height: 80rpx;
		padding-left: 20rpx;
	}

	.type {

		width: 308rpx;
		background: linear-gradient(180deg, rgba(22, 132, 252, 1) 0%, rgba(100, 174, 255, 1) 100%);
		color: rgba(255, 255, 255, 1);
		height: 80rpx;
		border-radius: 8rpx;

		line-height: 80rpx;
		text-align: center;

	}
</style>